﻿<Window x:Class="MainWindow4"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Visual_Studio_File_Cleanup.ViewModel"
    xmlns:converter="clr-namespace:Visual_Studio_File_Cleanup.Converters"
    Title="Visual Studio Solution Cleaner" Height="426" Width="695"
    DataContext="{DynamicResource Data}" Icon="Images/broom.png">
    <Window.Resources>
        <local:MainWindow x:Key="Data"/>
        <converter:SelectedToVisiability x:Key="SelectedVisiability"/>
        <Style TargetType="{x:Type CheckBox}">
            <Setter Property="Width" Value="200"/>
            <Setter Property="Margin" Value="10"/>
        </Style>

    </Window.Resources>
    <Window.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FFE8E8E8" Offset="0"/>
            <GradientStop Color="White" Offset="1"/>
        </LinearGradientBrush>
    </Window.Background>
    <Viewbox>
        <Grid DataContext="{Binding SolutionOptions}"  Height="426" Width="720">
            <DockPanel x:Name="MainContent">
                <DockPanel DockPanel.Dock="Left">
                    <Border  DockPanel.Dock="Bottom" BorderBrush="Gray"   BorderThickness="1,0,1,1" >
                        <Border.Background>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                <GradientStop Color="#33000000" Offset="0" />
                                <GradientStop Color="#11000000" Offset="1" />
                            </LinearGradientBrush>
                        </Border.Background>

                        <StackPanel HorizontalAlignment="Center" Margin="4"  Orientation="Horizontal" >
                            <TextBox x:Name="searchTextBox" Margin="6,0" Text="{Binding SearchText,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="150" />
                            <Button Command="{Binding SearchCommand}" Content="Search"   ToolTip="Search for the solution name with this text in it." Padding="8,0" />
                        </StackPanel>
                    </Border>
                    <TreeView ItemsSource="{Binding ChildOptions}"  x:Name="SolutionTree" >
                        <TreeView.Background>
                            <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                                <GradientStop Color="#FFF1EDED"/>
                                <GradientStop Color="White" Offset="1"/>
                            </LinearGradientBrush>
                        </TreeView.Background>
                        <TreeView.ItemContainerStyle>
                            <Style TargetType="{x:Type TreeViewItem}">
                                <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                                <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                                <Setter Property="FontWeight" Value="Normal" />
                                <Style.Triggers>
                                    <Trigger Property="IsSelected" Value="True">
                                        <Setter Property="FontWeight" Value="Bold" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </TreeView.ItemContainerStyle>

                        <TreeView.ItemTemplate>
                            <HierarchicalDataTemplate ItemsSource="{Binding ChildOptions}">
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding SolutionName}" />
                                </StackPanel>

                            </HierarchicalDataTemplate>
                        </TreeView.ItemTemplate>
                    </TreeView>
                </DockPanel>

                <Grid DataContext="{Binding ElementName=SolutionTree,Path=SelectedItem}" Visibility="{Binding ElementName=SolutionTree,Path=SelectedItem, Converter={StaticResource SelectedVisiability} }">
                    <DockPanel>
                        <StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom" HorizontalAlignment="Center">
                            <Button Command="{Binding AddChildCommand}" ToolTip="Add New Configuration" Margin="7" Padding="5" Content="Add"/>
                            <Button Command="{Binding SaveCommand}" ToolTip="Save Changes" Margin="7" Padding="5"  Content="Save Changes"/>
                            <Button Command="{Binding ZipCommand}" ToolTip="Zip all files under the root directory" Margin="7" Padding="5"  Content="Zip"/>
                            <Button Command="{Binding PopulateCommand}" ToolTip="Recurse Sub Directories to populate tree" Margin="7"  Padding="5" Content="Populate"/>
                            <Button Command="{Binding CleanCommand}" ToolTip="Clean Current Configuration" Margin="7" Padding="5" Content="Clean"/>
                            <Button Command="{Binding SetChildernCommand}" ToolTip="Set All Children options to match this." Padding="5" Margin="7"  Content="Set Children"/>
                            <Button Command="{Binding RemoveMeCommand}" ToolTip="Remove This Configuration" Margin="7" Padding="5" Content="Remove"/>
                        </StackPanel>
                        <StackPanel>

                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="120"/>
                                    <ColumnDefinition Width="200*"/>
                                    <ColumnDefinition Width="20*"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="Solution Name"/>
                                <TextBox Text="{Binding SolutionName, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}" Grid.Column="1" />
                            </Grid>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="120"/>
                                    <ColumnDefinition Width="200*"/>
                                    <ColumnDefinition Width="20*"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="Root Directory"/>
                                <TextBox Text="{Binding RootDirectory, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" Grid.Column="1"/>
                                <Button Command="{Binding OpenFolderCommand}" Grid.Column="2" ToolTip="Select the root Directory"  Content="..."></Button>
                            </Grid>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="120"/>
                                    <ColumnDefinition Width="200*"/>
                                    <ColumnDefinition Width="20*"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="Zip Output Directory"/>
                                <TextBox Text="{Binding ZipOutputDirectory, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" Grid.Column="1"/>
                                <Button Command="{Binding OpenFolderZipCommand}" Grid.Column="2" ToolTip="Select the Zip output Directory" Content="..."></Button>
                            </Grid>
                            <DockPanel>
                                <StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Center">
                                    <TextBlock Text="{Binding CurrentAction, IsAsync=True}"/>
                                </StackPanel>
                                <WrapPanel>
                                    <CheckBox VerticalAlignment="Center" IsChecked="{Binding RecurseThroughSubDirctories}" Grid.Column="1" ToolTip="Recurse Through Sub-Dirctories" >
                                        <TextBlock Text="Recurse Through Sub-Dirctories"/>
                                    </CheckBox>

                                    <CheckBox VerticalAlignment="Center" IsChecked="{Binding Suo}" Grid.Column="1" ToolTip="Note when you do delete the Suo File all your open tabs in VS will be gone. Very help full if VS crashes every time you open VS.">
                                        <TextBlock Text="Delete .Suo Files"/>
                                    </CheckBox>
                                    <CheckBox VerticalAlignment="Center" IsChecked="{Binding Webinfo}" Grid.Column="1" ToolTip="May help in opening web application if they will not open.">
                                        <TextBlock Text="Delete .Webinfo Files"/>
                                    </CheckBox>
                                    <CheckBox VerticalAlignment="Center" IsChecked="{Binding User}" Grid.Column="1" ToolTip="Can help if VS crashes on open.">
                                        <TextBlock Text="Delete .User Files"/>
                                    </CheckBox>
                                    <CheckBox VerticalAlignment="Center" IsChecked="{Binding CleanBin}" Grid.Column="1" ToolTip="Note bad practice to keep externally linked dll in the bin directory. Keep them in a separate out of project folder.">
                                        <TextBlock Text="Delete all files in the Bin directory"/>
                                    </CheckBox>
                                    <CheckBox VerticalAlignment="Center" IsChecked="{Binding CleanObj}" Grid.Column="1" ToolTip="Note bad practice to keep externally linked dll in the Obj directory. Keep them in a separate out of project folder.">
                                        <TextBlock Text="Delete all files in the Obj directory"/>
                                    </CheckBox>
                                    <CheckBox VerticalAlignment="Center" IsChecked="{Binding ClearReadOnlyFlag}" Grid.Column="1" ToolTip="Clear Readonly Flag on all files under the root directory">
                                        <TextBlock Text="Clear Readonly Flag"/>
                                    </CheckBox>

                                </WrapPanel>
                            </DockPanel>

                            <TextBlock Text="File Errors"/>
                            <ListView Height="133" Width="488" ItemsSource="{Binding FileErrorList}">
                                <ListView.Background>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FFDCD2D2" Offset="0"/>
                                        <GradientStop Color="White" Offset="1"/>
                                    </LinearGradientBrush>
                                </ListView.Background>
                            </ListView>


                        </StackPanel>

                    </DockPanel>

                </Grid>

            </DockPanel>
        </Grid>
    </Viewbox>
</Window>
